package com.doit.day01;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

public class HDFSTest {
    public static void main(String[] args) {
        System.setProperty("HADOOP_USER_NAME","root");
        try {
            FileSystem fs = FileSystem.get(new Configuration());
            // 本地文件路径
            Path localFilePath = new Path("D:\\output5.txt");
            // HDFS目标路径
            Path hdfsDestinationPath = new Path("/");
            // 上传文件
            fs.copyFromLocalFile(localFilePath, hdfsDestinationPath);
            System.out.println("File uploaded successfully.");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
